package com.zsy.mybatis.test.dao;

import com.zsy.mybatis.binding.MapperProxyFactory;
import com.zsy.mybatis.test.dao.dao.IUserDao;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;

/**
 * @auther Kea
 * @description
 * @create 2025-04-13 14:27
 */


public class ApiTest {
    private Logger logger = LoggerFactory.getLogger(ApiTest.class);
    @Test
    public void test_MapperProxyFactory(){
        MapperProxyFactory<IUserDao> iUserDaoMapperProxyFactory = new MapperProxyFactory<>(IUserDao.class);
        Map<String,String> sqlSession = new HashMap<>();

        sqlSession.put("com.zsy.mybatis.test.dao.dao.IUserDao.queryUserId", "模拟执行 Mapper.xml 中 SQL 语句的操作：查询用户姓名");
        sqlSession.put("com.zsy.mybatis.test.dao.dao.IUserDao.queryUserAge", "模拟执行 Mapper.xml 中 SQL 语句的操作：查询用户年龄");

        IUserDao iUserDao = iUserDaoMapperProxyFactory.newInstance(sqlSession);
        String result = iUserDao.queryUserId("1");

        logger.info("测试结果：{}", result);
    }
}
